package com.qyer.log;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.qyer.words.model.Word;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qyer.search.Constants;

import java.util.List;
import java.util.Set;

/**
 * Created by tangzheng on 16/3/24.
 */
public class PhraseShowLogger {

  private static final Logger LOGGER = LoggerFactory.getLogger(PhraseShowLogger.class);

  public static void logSplitResult(String etlRequestId,String requestId, String strategy, Word translation) throws
    JsonProcessingException {
    if (translation == null) {
      return;
    }
    StringBuilder sb = new StringBuilder();
    sb.append(requestId);
    sb.append(Constants.SEPARATOR2);
    sb.append(etlRequestId);
    sb.append(Constants.SEPARATOR2);
    sb.append(strategy);
    sb.append(Constants.SEPARATOR2);
    sb.append(translation.getName());
    sb.append(Constants.SEPARATOR2);
    sb.append(translation.getFirstImpression().name());

    LOGGER.info(sb.toString());


    /*for (List<Word> candidateWords : translation) {
      if(candidateWords == null)
        continue;
      for(int i = 0; i < candidateWords.size(); i++){
        StringBuilder sb = new StringBuilder();
        sb.append(etlRequestId);
        sb.append(Constants.SEPARATOR2);
        sb.append(requestId);
        sb.append(Constants.SEPARATOR2);
        sb.append(candidateWords.get(i).getName());
        sb.append(Constants.SEPARATOR2);
        sb.append(candidateWords.get(i).getFirstImpression().name());
        LOGGER.info(sb.toString());
      }
    }*/
  }

  public static void logSplitResult(String etlRequestId,String requestId, String strategy, String name, String type) throws
    JsonProcessingException {
    if (name == null) {
      return;
    }
    StringBuilder sb = new StringBuilder();
    sb.append(requestId);
    sb.append(Constants.SEPARATOR2);
    sb.append(etlRequestId);
    sb.append(Constants.SEPARATOR2);
    sb.append(strategy);
    sb.append(Constants.SEPARATOR2);
    sb.append(name);
    sb.append(Constants.SEPARATOR2);
    sb.append(type);

    LOGGER.info(sb.toString());
  }
}
